﻿@using Microsoft.AspNetCore.Components
@using System.Globalization;
@namespace MudBlazor.Docs.Examples

<MudGrid>
    <MudItem xs="12" sm="6" md="4">
        <MudSelect Label="Select fast-food" @bind-Value="stringValue" HelperText="String"
                   OffsetY="true" AdornmentIcon="@Icons.Material.Filled.Fastfood" AdornmentColor="Color.Primary">
            <MudSelectItem Value="@("Pizza")" Disabled="true">Pizza (Disabled)</MudSelectItem>
            <MudSelectItem Value="@("Burger")">Burger</MudSelectItem>
            <MudSelectItem Value="@("Hotdog")">Hot Dog</MudSelectItem>
        </MudSelect>
    </MudItem>
    <MudItem xs="12" sm="6" md="4">
        <MudSelect Label="Select drink" @bind-Value="enumValue" HelperText="Enum"
                   OffsetY="true" OpenIcon="@Icons.Material.Filled.LocalDrink" AdornmentColor="Color.Secondary">
            @foreach (Drink item in Enum.GetValues(typeof(Drink)))
            {
                <MudSelectItem Value="@item">@item</MudSelectItem>
            }
        </MudSelect>
    </MudItem>
    <MudItem xs="12" sm="6" md="4">
        <MudSelect Placeholder="Select culture" @bind-Value="cultureValue" HelperText="CultureInfo" ToStringFunc="@convertFunc"
                   OffsetY="true" CloseIcon="@Icons.Material.Filled.Flag" AdornmentColor="Color.Tertiary">
            <MudSelectItem Value="@(CultureInfo.GetCultureInfo("en-US"))"></MudSelectItem>
            <MudSelectItem Value="@(CultureInfo.GetCultureInfo("de-AT"))"></MudSelectItem>
            <MudSelectItem Value="@(CultureInfo.GetCultureInfo("pt-BR"))"></MudSelectItem>
            <MudSelectItem Value="@(CultureInfo.GetCultureInfo("zh-CN"))"/>
        </MudSelect>
    </MudItem>
    <MudItem xs="12" md="12">
        <MudText Class="mb-n3" Typo="Typo.body2">
            Selected values: 
            <MudChip>@(stringValue ?? "Select fast-food")</MudChip>
            <MudChip Color="Color.Primary">@enumValue</MudChip>
            <MudChip Color="Color.Secondary">@(cultureValue?.DisplayName ?? "Select culture")</MudChip>
        </MudText>
    </MudItem>
</MudGrid>



@code {
    private string stringValue { get; set; }
    private Drink enumValue { get; set; }
    public enum Drink { Tee, SparklingWater, SoftDrink, Cider, Beer, Wine, Moonshine }
    private CultureInfo cultureValue { get; set; }
    private Func<CultureInfo, string> convertFunc = ci => ci?.DisplayName;
}
